(0) Obligation:

The Runtime Complexity (innermost) of the given CpxTRS could be proven to be BOUNDS(1, n^2).


The TRS R consists of the following rules:

f(true, x, y) → f(gt(x, y), x, round(s(y)))
round(0) → 0
round(s(0)) → s(s(0))
round(s(s(x))) → s(s(round(x)))
gt(0, v) → false
gt(s(u), 0) → true
gt(s(u), s(v)) → gt(u, v)

Rewrite Strategy: INNERMOST

(1) TrsToWeightedTrsProof (BOTH BOUNDS(ID, ID) transformation)

Transformed TRS to weighted TRS

(2) Obligation:

The Runtime Complexity (innermost) of the given CpxWeightedTrs could be proven to be BOUNDS(1, n^2).


The TRS R consists of the following rules:

f(true, x, y) → f(gt(x, y), x, round(s(y))) [1]
round(0) → 0 [1]
round(s(0)) → s(s(0)) [1]
round(s(s(x))) → s(s(round(x))) [1]
gt(0, v) → false [1]
gt(s(u), 0) → true [1]
gt(s(u), s(v)) → gt(u, v) [1]

Rewrite Strategy: INNERMOST

(3) TypeInferenceProof (BOTH BOUNDS(ID, ID) transformation)

Infered types.

(4) Obligation:

Runtime Complexity Weighted TRS with Types.
The TRS R consists of the following rules:

f(true, x, y) → f(gt(x, y), x, round(s(y))) [1]
round(0) → 0 [1]
round(s(0)) → s(s(0)) [1]
round(s(s(x))) → s(s(round(x))) [1]
gt(0, v) → false [1]
gt(s(u), 0) → true [1]
gt(s(u), s(v)) → gt(u, v) [1]

The TRS has the following type information:
f :: true:false → s:0 → s:0 → f
true :: true:false
gt :: s:0 → s:0 → true:false
round :: s:0 → s:0
s :: s:0 → s:0
0 :: s:0
false :: true:false

Rewrite Strategy: INNERMOST

(5) CompletionProof (UPPER BOUND(ID) transformation)

The TRS is a completely defined constructor system, as every type has a constant constructor and the following rules were added:

f(v0, v1, v2) → null_f [0]

And the following fresh constants:

null_f

(6) Obligation:

Runtime Complexity Weighted TRS where all functions are completely defined. The underlying TRS is:

Runtime Complexity Weighted TRS with Types.
The TRS R consists of the following rules:

f(true, x, y) → f(gt(x, y), x, round(s(y))) [1]
round(0) → 0 [1]
round(s(0)) → s(s(0)) [1]
round(s(s(x))) → s(s(round(x))) [1]
gt(0, v) → false [1]
gt(s(u), 0) → true [1]
gt(s(u), s(v)) → gt(u, v) [1]
f(v0, v1, v2) → null_f [0]

The TRS has the following type information:
f :: true:false → s:0 → s:0 → null_f
true :: true:false
gt :: s:0 → s:0 → true:false
round :: s:0 → s:0
s :: s:0 → s:0
0 :: s:0
false :: true:false
null_f :: null_f

Rewrite Strategy: INNERMOST

(7) CpxTypedWeightedTrsToRntsProof (UPPER BOUND(ID) transformation)

Transformed the TRS into an over-approximating RNTS by (improved) Size Abstraction.
The constant constructors are abstracted as follows:

true => 1
0 => 0
false => 0
null_f => 0

(8) Obligation:

Complexity RNTS consisting of the following rules:

f(z, z', z'') -{ 1 }→ f(gt(x, y), x, round(1 + y)) :|: z' = x, z'' = y, z = 1, x >= 0, y >= 0
f(z, z', z'') -{ 0 }→ 0 :|: v0 >= 0, z'' = v2, v1 >= 0, z = v0, z' = v1, v2 >= 0
gt(z, z') -{ 1 }→ gt(u, v) :|: v >= 0, z' = 1 + v, z = 1 + u, u >= 0
gt(z, z') -{ 1 }→ 1 :|: z = 1 + u, z' = 0, u >= 0
gt(z, z') -{ 1 }→ 0 :|: v >= 0, z' = v, z = 0
round(z) -{ 1 }→ 0 :|: z = 0
round(z) -{ 1 }→ 1 + (1 + round(x)) :|: x >= 0, z = 1 + (1 + x)
round(z) -{ 1 }→ 1 + (1 + 0) :|: z = 1 + 0

Only complete derivations are relevant for the runtime complexity.

(9) CompleteCoflocoProof (EQUIVALENT transformation)

Transformed the RNTS (where only complete derivations are relevant) into cost relations for CoFloCo:

eq(start(V, V1, V2),0,[f(V, V1, V2, Out)],[V >= 0,V1 >= 0,V2 >= 0]).
eq(start(V, V1, V2),0,[round(V, Out)],[V >= 0]).
eq(start(V, V1, V2),0,[gt(V, V1, Out)],[V >= 0,V1 >= 0]).
eq(f(V, V1, V2, Out),1,[gt(V3, V4, Ret0),round(1 + V4, Ret2),f(Ret0, V3, Ret2, Ret)],[Out = Ret,V1 = V3,V2 = V4,V = 1,V3 >= 0,V4 >= 0]).
eq(round(V, Out),1,[],[Out = 0,V = 0]).
eq(round(V, Out),1,[],[Out = 2,V = 1]).
eq(round(V, Out),1,[round(V5, Ret11)],[Out = 2 + Ret11,V5 >= 0,V = 2 + V5]).
eq(gt(V, V1, Out),1,[],[Out = 0,V6 >= 0,V1 = V6,V = 0]).
eq(gt(V, V1, Out),1,[],[Out = 1,V = 1 + V7,V1 = 0,V7 >= 0]).
eq(gt(V, V1, Out),1,[gt(V8, V9, Ret1)],[Out = Ret1,V9 >= 0,V1 = 1 + V9,V = 1 + V8,V8 >= 0]).
eq(f(V, V1, V2, Out),0,[],[Out = 0,V10 >= 0,V2 = V11,V12 >= 0,V = V10,V1 = V12,V11 >= 0]).
input_output_vars(f(V,V1,V2,Out),[V,V1,V2],[Out]).
input_output_vars(round(V,Out),[V],[Out]).
input_output_vars(gt(V,V1,Out),[V,V1],[Out]).

CoFloCo proof output:
Preprocessing Cost Relations
=====================================

#### Computed strongly connected components
0. recursive : [gt/3]
1. recursive : [round/2]
2. recursive : [f/4]
3. non_recursive : [start/3]

#### Obtained direct recursion through partial evaluation
0. SCC is partially evaluated into gt/3
1. SCC is partially evaluated into round/2
2. SCC is partially evaluated into f/4
3. SCC is partially evaluated into start/3

Control-Flow Refinement of Cost Relations
=====================================

### Specialization of cost equations gt/3
* CE 12 is refined into CE [13]
* CE 11 is refined into CE [14]
* CE 10 is refined into CE [15]


### Cost equations --> "Loop" of gt/3
* CEs [14] --> Loop 10
* CEs [15] --> Loop 11
* CEs [13] --> Loop 12

### Ranking functions of CR gt(V,V1,Out)
* RF of phase [12]: [V,V1]

#### Partial ranking functions of CR gt(V,V1,Out)
* Partial RF of phase [12]:
- RF of loop [12:1]:
V
V1


### Specialization of cost equations round/2
* CE 9 is refined into CE [16]
* CE 8 is refined into CE [17]
* CE 7 is refined into CE [18]


### Cost equations --> "Loop" of round/2
* CEs [17] --> Loop 13
* CEs [18] --> Loop 14
* CEs [16] --> Loop 15

### Ranking functions of CR round(V,Out)
* RF of phase [15]: [V-1]

#### Partial ranking functions of CR round(V,Out)
* Partial RF of phase [15]:
- RF of loop [15:1]:
V-1


### Specialization of cost equations f/4
* CE 6 is refined into CE [19]
* CE 5 is refined into CE [20,21,22,23,24,25,26,27]


### Cost equations --> "Loop" of f/4
* CEs [26] --> Loop 16
* CEs [27] --> Loop 17
* CEs [25] --> Loop 18
* CEs [24] --> Loop 19
* CEs [23] --> Loop 20
* CEs [22] --> Loop 21
* CEs [21] --> Loop 22
* CEs [20] --> Loop 23
* CEs [19] --> Loop 24

### Ranking functions of CR f(V,V1,V2,Out)
* RF of phase [16,17]: [V1-V2]

#### Partial ranking functions of CR f(V,V1,V2,Out)
* Partial RF of phase [16,17]:
- RF of loop [16:1]:
V1/2-V2/2
- RF of loop [17:1]:
V1-V2


### Specialization of cost equations start/3
* CE 2 is refined into CE [28,29,30,31,32]
* CE 3 is refined into CE [33,34,35,36]
* CE 4 is refined into CE [37,38,39,40]


### Cost equations --> "Loop" of start/3
* CEs [35,36,40] --> Loop 25
* CEs [39] --> Loop 26
* CEs [28] --> Loop 27
* CEs [38] --> Loop 28
* CEs [29,30,31,32,34] --> Loop 29
* CEs [33,37] --> Loop 30

### Ranking functions of CR start(V,V1,V2)

#### Partial ranking functions of CR start(V,V1,V2)


Computing Bounds
=====================================

#### Cost of chains of gt(V,V1,Out):
* Chain [[12],11]: 1*it(12)+1
Such that:it(12) =< V

with precondition: [Out=0,V>=1,V1>=V]

* Chain [[12],10]: 1*it(12)+1
Such that:it(12) =< V1

with precondition: [Out=1,V1>=1,V>=V1+1]

* Chain [11]: 1
with precondition: [V=0,Out=0,V1>=0]

* Chain [10]: 1
with precondition: [V1=0,Out=1,V>=1]


#### Cost of chains of round(V,Out):
* Chain [[15],14]: 1*it(15)+1
Such that:it(15) =< Out

with precondition: [V=Out,V>=2]

* Chain [[15],13]: 1*it(15)+1
Such that:it(15) =< Out

with precondition: [V+1=Out,V>=3]

* Chain [14]: 1
with precondition: [V=0,Out=0]

* Chain [13]: 1
with precondition: [V=1,Out=2]


#### Cost of chains of f(V,V1,V2,Out):
* Chain [[16,17],24]: 3*it(16)+3*it(17)+2*s(9)+2*s(11)+0
Such that:aux(3) =< V1+1
aux(5) =< V1-V2
aux(6) =< V1-V2+1
it(16) =< V1/2-V2/2
it(16) =< aux(5)
it(17) =< aux(5)
it(16) =< aux(6)
it(17) =< aux(6)
aux(4) =< aux(3)-1
s(10) =< it(16)*aux(3)
s(12) =< it(17)*aux(4)
s(11) =< s(12)
s(9) =< s(10)

with precondition: [V=1,Out=0,V2>=1,V1>=V2+1]

* Chain [[16,17],19,24]: 3*it(16)+3*it(17)+2*s(9)+2*s(11)+1*s(13)+1*s(14)+3
Such that:s(13) =< V1
aux(3) =< V1+1
s(14) =< V1+3
aux(5) =< V1-V2
aux(6) =< V1-V2+1
it(16) =< V1/2-V2/2
it(16) =< aux(5)
it(17) =< aux(5)
it(16) =< aux(6)
it(17) =< aux(6)
aux(4) =< aux(3)-1
s(10) =< it(16)*aux(3)
s(12) =< it(17)*aux(4)
s(11) =< s(12)
s(9) =< s(10)

with precondition: [V=1,Out=0,V2>=1,V1>=V2+1]

* Chain [[16,17],18,24]: 3*it(16)+3*it(17)+2*s(9)+2*s(11)+1*s(15)+1*s(16)+3
Such that:s(15) =< V1
aux(3) =< V1+1
s(16) =< V1+2
aux(5) =< V1-V2
aux(6) =< V1-V2+1
it(16) =< V1/2-V2/2
it(16) =< aux(5)
it(17) =< aux(5)
it(16) =< aux(6)
it(17) =< aux(6)
aux(4) =< aux(3)-1
s(10) =< it(16)*aux(3)
s(12) =< it(17)*aux(4)
s(11) =< s(12)
s(9) =< s(10)

with precondition: [V=1,Out=0,V2>=1,V1>=V2+1]

* Chain [24]: 0
with precondition: [Out=0,V>=0,V1>=0,V2>=0]

* Chain [23,24]: 3
with precondition: [V=1,V1=0,V2=0,Out=0]

* Chain [22,24]: 1*s(17)+3
Such that:s(17) =< V2+2

with precondition: [V=1,V1=0,Out=0,V2>=2]

* Chain [21,24]: 1*s(18)+3
Such that:s(18) =< V2+1

with precondition: [V=1,V1=0,Out=0,V2>=1]

* Chain [20,[16,17],24]: 3*it(16)+3*it(17)+2*s(9)+2*s(11)+3
Such that:aux(3) =< V1+1
it(16) =< V1/2
aux(7) =< V1
it(16) =< aux(7)
it(17) =< aux(7)
aux(4) =< aux(3)-1
s(10) =< it(16)*aux(3)
s(12) =< it(17)*aux(4)
s(11) =< s(12)
s(9) =< s(10)

with precondition: [V=1,V2=0,Out=0,V1>=3]

* Chain [20,[16,17],19,24]: 3*it(16)+4*it(17)+2*s(9)+2*s(11)+1*s(14)+6
Such that:aux(3) =< V1+1
s(14) =< V1+3
it(16) =< V1/2
aux(8) =< V1
it(17) =< aux(8)
it(16) =< aux(8)
aux(4) =< aux(3)-1
s(10) =< it(16)*aux(3)
s(12) =< it(17)*aux(4)
s(11) =< s(12)
s(9) =< s(10)

with precondition: [V=1,V2=0,Out=0,V1>=3]

* Chain [20,[16,17],18,24]: 3*it(16)+4*it(17)+2*s(9)+2*s(11)+1*s(16)+6
Such that:aux(3) =< V1+1
s(16) =< V1+2
it(16) =< V1/2
aux(9) =< V1
it(17) =< aux(9)
it(16) =< aux(9)
aux(4) =< aux(3)-1
s(10) =< it(16)*aux(3)
s(12) =< it(17)*aux(4)
s(11) =< s(12)
s(9) =< s(10)

with precondition: [V=1,V2=0,Out=0,V1>=3]

* Chain [20,24]: 3
with precondition: [V=1,V2=0,Out=0,V1>=1]

* Chain [20,19,24]: 1*s(13)+1*s(14)+6
Such that:s(14) =< 4
s(13) =< V1

with precondition: [V=1,V2=0,Out=0,2>=V1,V1>=1]

* Chain [20,18,24]: 1*s(15)+1*s(16)+6
Such that:s(16) =< 3
s(15) =< V1

with precondition: [V=1,V2=0,Out=0,2>=V1,V1>=1]

* Chain [19,24]: 1*s(13)+1*s(14)+3
Such that:s(13) =< V1
s(14) =< V2+2

with precondition: [V=1,Out=0,V1>=1,V2>=2,V2>=V1]

* Chain [18,24]: 1*s(15)+1*s(16)+3
Such that:s(15) =< V1
s(16) =< V2+1

with precondition: [V=1,Out=0,V1>=1,V2>=V1]


#### Cost of chains of start(V,V1,V2):
* Chain [30]: 1
with precondition: [V=0]

* Chain [29]: 2*s(92)+2*s(93)+1*s(94)+1*s(95)+2*s(96)+2*s(97)+17*s(101)+9*s(102)+6*s(106)+6*s(107)+9*s(120)+9*s(121)+6*s(125)+6*s(126)+6
Such that:s(94) =< 3
s(95) =< 4
s(116) =< V1-V2
s(117) =< V1-V2+1
s(100) =< V1/2
s(118) =< V1/2-V2/2
aux(19) =< V1
aux(20) =< V1+1
aux(21) =< V1+2
aux(22) =< V1+3
aux(23) =< V2+1
aux(24) =< V2+2
s(96) =< aux(21)
s(97) =< aux(22)
s(92) =< aux(23)
s(93) =< aux(24)
s(101) =< aux(19)
s(102) =< s(100)
s(102) =< aux(19)
s(103) =< aux(20)-1
s(104) =< s(102)*aux(20)
s(105) =< s(101)*s(103)
s(106) =< s(105)
s(107) =< s(104)
s(120) =< s(118)
s(120) =< s(116)
s(121) =< s(116)
s(120) =< s(117)
s(121) =< s(117)
s(123) =< s(120)*aux(20)
s(124) =< s(121)*s(103)
s(125) =< s(124)
s(126) =< s(123)

with precondition: [V=1]

* Chain [28]: 1
with precondition: [V1=0,V>=1]

* Chain [27]: 3
with precondition: [V>=0,V1>=0,V2>=0]

* Chain [26]: 1*s(127)+1
Such that:s(127) =< V

with precondition: [V>=1,V1>=V]

* Chain [25]: 1*s(128)+1*s(129)+1*s(130)+1
Such that:s(129) =< V
s(128) =< V+1
s(130) =< V1

with precondition: [V>=2]


Closed-form bounds of start(V,V1,V2):
-------------------------------------
* Chain [30] with precondition: [V=0]
- Upper bound: 1
- Complexity: constant
* Chain [29] with precondition: [V=1]
- Upper bound: nat(V1)*17+13+nat(nat(V1+1)+ -1)*6*nat(V1)+nat(nat(V1+1)+ -1)*6*nat(V1-V2)+nat(V1+1)*6*nat(V1/2-V2/2)+nat(V1+1)*6*nat(V1/2)+nat(V1+2)*2+nat(V1+3)*2+nat(V2+1)*2+nat(V2+2)*2+nat(V1-V2)*9+nat(V1/2-V2/2)*9+nat(V1/2)*9
- Complexity: n^2
* Chain [28] with precondition: [V1=0,V>=1]
- Upper bound: 1
- Complexity: constant
* Chain [27] with precondition: [V>=0,V1>=0,V2>=0]
- Upper bound: 3
- Complexity: constant
* Chain [26] with precondition: [V>=1,V1>=V]
- Upper bound: V+1
- Complexity: n
* Chain [25] with precondition: [V>=2]
- Upper bound: V+1+nat(V1)+ (V+1)
- Complexity: n

### Maximum cost of start(V,V1,V2): max([max([2,nat(V1)*17+12+nat(nat(V1+1)+ -1)*6*nat(V1)+nat(nat(V1+1)+ -1)*6*nat(V1-V2)+nat(V1+1)*6*nat(V1/2-V2/2)+nat(V1+1)*6*nat(V1/2)+nat(V1+2)*2+nat(V1+3)*2+nat(V2+1)*2+nat(V2+2)*2+nat(V1-V2)*9+nat(V1/2-V2/2)*9+nat(V1/2)*9]),V+1+nat(V1)+V])+1
Asymptotic class: n^2
* Total analysis performed in 428 ms.

(10) BOUNDS(1, n^2)